{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-card-header">
            <i class="fa fa-pencil"></i> 编辑会员级别
        </div>
        <form class="layui-form" action="">
            <input type="hidden" name="id" value="{$info.level_id}" />
            <div class="layui-form-item">
                <label class="layui-form-label">等级名称</label>
                <div class="layui-input-inline layui-input-wrap">
                    <input type="text" name="level_name" lay-verify="required" value="{$info.level_name}" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">字段值</label>
                <div class="layui-input-inline layui-input-wrap">
                    <input type="text" name="rank" lay-verify="required" placeholder="请输入" value="{$info.rank}" readonly autocomplete="off" class="layui-input">
                </div>
            </div>
            <fieldset class="layui-elem-field">
                <legend>升级条件</legend>
                <div class="layui-field-box">
                    <div class="layui-form-item" >
                        <label class="layui-form-label">升级条件</label>
                        <div class="layui-input-inline layui-module-itemL">
                            <div>一次性购物金额满</div>
                            <input   type="text" name="up_money" class="layui-input" value="{$info.up_money}">
                            元
                        </div>
                        <div class="layui-form-mid layui-word-aux">（报单区）</div>
                    </div>
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>分销设置</legend>
                <div class="layui-field-box">
                    <div class="layui-form-item" >
                        <label class="layui-form-label">提成比例</label>
                        <div class="layui-input-inline layui-module-itemL">
                            <div>一级</div>
                            <input   type="text" name="intro_bili1" class="layui-input" value="{$info.intro_bili}">%
                        </div>
                        <div class="layui-input-inline layui-module-itemL">
                            <div>二级</div>
                            <input   type="text" name="intro_bili2" class="layui-input" value="{$info.intro_bili}">%
                        </div>
                        <div class="layui-input-inline layui-module-itemL">
                            <div>三级</div>
                            <input   type="text" name="intro_bili3" class="layui-input" value="{$info.intro_bili}">%
                        </div>
                        <div class="layui-form-mid layui-word-aux">推荐下级购物获得提成比例</div>
                    </div>
                </div>
            </fieldset>

            <div class="layui-form-item">
                <label class="layui-form-label">等级描述</label>
                <div class="layui-input-inline layui-input-wrap">
                    <textarea name="desc" placeholder="请输入内容" class="layui-textarea">{$info.describe}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="subbtn">确认</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script>
    layui.use(['form', 'laydate', 'util'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });

        // 指定开关事件
        // form.on('switch(switchTest)', function(data){
        //     layer.msg('开关 checked：'+ (this.checked ? 'true' : 'false'), {
        //         offset: '6px'
        //     });
        //     layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是 ON|OFF', data.othis)
        // });

        // 提交事件
        form.on('submit(subbtn)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('save')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('提交成功');
                    }else{
                        layer.msg(res.msg);
                    }
                    setTimeout(function(){
                        parent.layer.closeAll();
                        parent.tableIns.reload()
                    },1000)
                }
            });
            return false; // 阻止默认 form 跳转
        });

        // 日期
        laydate.render({
            elem: '#date'
        });


    });
</script>
</body>
</html>